import baostock as bs
import pandas as pd
import datetime
import json

def load_all_list():
    df = pd.read_csv('./stk_data/all_list.csv', encoding='gbk')
    # print(df)
    # print(type(df))
    return df

if __name__ == '__main__':
    all_df = load_all_list()

    codes = all_df.code.values
    names = all_df.code_name.values

    stock = dict(zip(names, codes))
    # print(stock)

    stock_index = dict([('股票', stock)])

    # dump: 将数据写入 json 文件中
    with open("stock_pool_baostock.json", "w", encoding='utf-8') as f:
        json.dump(stock_index, f, ensure_ascii=False, indent=4)